<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // 实际上，在cookie中，名称是唯一的(同一有效期内)


        // 最终只会存储cc
        // document.cookie = 'username=aa' ;
        // document.cookie = 'username=bb' ;
        // document.cookie = 'username=cc' ;

        // 存多组账号和密码
        document.cookie = 'yy=123';
        document.cookie = 'aa=222';
        document.cookie = 'cc=456';


        // 读取数据
        let cookies = document.cookie;

        let arr = cookies.split('; ');
        console.log(arr);

        arr = arr.map(v => {
            let arr = v.split('=');
            return {
                name: arr[0],
                content: arr[1]
            }
        })

        console.log(arr);


        




    </script>

</body>

</html>